﻿// Copyright (c) Autofac Project. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace Autofac.Core;

/// <summary>
/// Defines an interface for accessing the set of services available during pipeline build time.
/// </summary>
public interface IComponentRegistryServices
{
    /// <summary>
    /// Selects from the available registrations after ensuring that any
    /// dynamic registration sources that may provide <paramref name="service"/>
    /// have been invoked.
    /// </summary>
    /// <param name="service">The service for which registrations are sought.</param>
    /// <returns>Registrations supporting <paramref name="service"/>.</returns>
    IEnumerable<IComponentRegistration> RegistrationsFor(Service service);

    /// <summary>
    /// Attempts to find a default registration for the specified service.
    /// </summary>
    /// <param name="service">The service to look up.</param>
    /// <param name="registration">The default registration for the service.</param>
    /// <returns>True if a registration exists.</returns>
    bool TryGetRegistration(Service service, [NotNullWhen(returnValue: true)] out IComponentRegistration? registration);

    /// <summary>
    /// Determines whether the specified service is registered.
    /// </summary>
    /// <param name="service">The service to test.</param>
    /// <returns>True if the service is registered.</returns>
    bool IsRegistered(Service service);
}
